package com.rongc.client.freight.business.supply.view.popup;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.rongc.client.freight.R;
import com.rongc.client.freight.base.view.adapter.RecyclerBaseAdapter;
import com.rongc.client.freight.base.view.widget.DividerItemDecoration;

/**
 * Created by Bruce on 2017/7/7.
 */
public class SupplyPopup {

    /**
     * 筛选 popup
     * @param context
     * @return
     */
    public static PopupWindow makePopupLQMoreOption(Context context , final RecyclerBaseAdapter mAdapter, View.OnClickListener mListener) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View vPopupWindow = inflater.inflate(
                R.layout.popup_recycler, null, false);

        vPopupWindow.findViewById(R.id.btn_cancel).setOnClickListener(mListener);

        RecyclerView mRecyclerViewSF = (RecyclerView) vPopupWindow.findViewById(R.id.recycler);
        mRecyclerViewSF.addItemDecoration(new DividerItemDecoration(context,DividerItemDecoration.VERTICAL_LIST));
        mRecyclerViewSF.setLayoutManager(new LinearLayoutManager(context));
        mRecyclerViewSF.setAdapter(mAdapter);

        PopupWindow pw = new PopupWindow(vPopupWindow, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT ,true);
        pw.setContentView(vPopupWindow);
//		pw.setAnimationStyle(R.style.AnimationPreview);
        pw.setFocusable(true);
		/*设置背景显示*/
        ColorDrawable dw = new ColorDrawable(0xffffffff);
        pw.setBackgroundDrawable(dw);
        pw.update();
	    /*设置触摸外面时消失*/
        pw.setOutsideTouchable(true);
        pw.setTouchable(true);
        return pw;
    }

}
